public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int num = sc.nextInt();
            if(num == 0) return ;
            int number = pressurizedBottle(num);
            System.out.println(number);
        }
        sc.close();
        
        
    }
    
    public static int pressurizedBottle(int num){
        if(num == 0 || num == 1) return 0;
        
        int sum = 0; //代表换到汽水的数量
        while(num >= 3){
            int re = num % 3;
            sum += num/3;
            num = num/3 + re;  //更新手里剩余的空瓶
        }
        if(num == 2){
            sum++;
        }
        return sum;
    }
}